package com.tomato.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tomato.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    /**
     * 根据手机号查询用户
     * @param phone 手机号
     * @return 用户实体
     */
    @Select("SELECT * FROM user WHERE phone = #{phone}")
    User selectByPhone(@Param("phone") String phone);

    /**
     * 更新用户头像路径
     * @param userId 用户ID
     * @param avatarPath 头像路径
     * @return 影响行数
     */
    @Update("UPDATE user SET avatar_path = #{avatarPath} WHERE id = #{userId}")
    int updateAvatar(@Param("userId") Long userId, @Param("avatarPath") String avatarPath);
}